package bat.ke.qq.com.core;

import bat.ke.qq.com.bean.User;
import bat.ke.qq.com.mapper.UserMapper;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.stereotype.Component;

import java.lang.reflect.Proxy;

/**
 *
 *
 *
 *
 */
//@Component
public class MyFactoryBean implements FactoryBean {

    private Class mapperInterface;

    public MyFactoryBean(Class mapperInterface) {
        this.mapperInterface = mapperInterface;
    }

    @Override
    public Object getObject() throws Exception {
        return Proxy.newProxyInstance(this.getClass().getClassLoader(),new Class[]{mapperInterface},new ProxyInvocationHandler());
    }

    @Override
    public Class<?> getObjectType() {
        return mapperInterface;
    }

}
